package com.longfei.admin.diary_longfei;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;

/**
 * Created by longfei on 2016/6/13.
 */
public class Welcome_Activity extends Activity {
    protected LinearLayout leftLayout;
    protected LinearLayout rightLayout;
    protected LinearLayout welcome_Layout;

    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);//取消标题栏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //屏幕全屏

        setContentView(R.layout.welcome_activity);
        
        init();

    }

    private void init() {

        leftLayout = (LinearLayout)findViewById(R.id.welcome_leftlayout);
        rightLayout = (LinearLayout)findViewById(R.id.welcome_rightlayout);
        welcome_Layout = (LinearLayout)findViewById(R.id.welcome_layout1);

        welcome_Layout.setBackgroundResource(R.drawable.main_bg);

        //加载开门动画
        Animation leftOutAnimation = AnimationUtils.loadAnimation(
                getApplicationContext(),R.xml.translate_left);
        Animation rightOutAnimation=AnimationUtils.loadAnimation(
                getApplicationContext(),R.xml.trabslate_right);

        //设置动画,左布局向左移动，右布局向右移动
        leftLayout.setAnimation(leftOutAnimation);
        rightLayout.setAnimation(rightOutAnimation);

        //设置动画监听器
        leftOutAnimation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                //动画结束时，隐藏布局
                leftLayout.setVisibility(View.GONE);
                rightLayout.setVisibility(View.GONE);
                Intent intent=new Intent();
                intent.setClass(Welcome_Activity.this,Access.class);
                overridePendingTransition(0, 0);
                Welcome_Activity.this.finish();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });


    }
}
